// @ts-ignore
import Idle1Png from "res://assets/knight/Idle (1).png"
// @ts-ignore
import Run1Png from "res://assets/knight/Run (1).png"
// @ts-ignore
import Run2Png from "res://assets/knight/Run (2).png"
// @ts-ignore
import Run3Png from "res://assets/knight/Run (3).png"
// @ts-ignore
import Run4Png from "res://assets/knight/Run (4).png"
// @ts-ignore
import Run5Png from "res://assets/knight/Run (5).png"
// @ts-ignore
import Run6Png from "res://assets/knight/Run (6).png"
// @ts-ignore
import Run7Png from "res://assets/knight/Run (7).png"
// @ts-ignore
import Run8Png from "res://assets/knight/Run (8).png"
// @ts-ignore
import Run9Png from "res://assets/knight/Run (9).png"
// @ts-ignore
import Run10Png from "res://assets/knight/Run (10).png"


export default class KnightAniSpr extends godot.AnimatedSprite {
    frameIndex = 10;
    frameStart = 0;
    frameEnd = 9;
    

    runFrame = "RUN"
    idleFrame ="IDLE"

    constructor() {
        super()
        this.initFrames();
        this.position = new godot.Vector2(300,300)
    }

    initFrames(){
        
        let sprFrames = new godot.SpriteFrames();
        let textureArr = [
            Run1Png,
            Run2Png,
            Run3Png,
            Run4Png,
            Run5Png,
            Run6Png,
            Run7Png,
            Run8Png,
            Run9Png,
            Run10Png,
        ];
        sprFrames.add_animation(this.runFrame)
        sprFrames.set_animation_loop(this.runFrame,true);
        sprFrames.set_animation_speed(this.runFrame,20)


        textureArr.forEach((v,i)=>{
            sprFrames.set_frame(this.runFrame,i,v);
        })
        sprFrames.add_animation(this.idleFrame)
        sprFrames.set_frame(this.idleFrame,0,Idle1Png);

        this.frames = sprFrames
        this.animation = this.idleFrame;

        this.play(this.runFrame);

    }
}